import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;

public class AuctionItemStoreImpl implements AuctionItemStore {

	private List<AuctionItem> auctionItemList = Collections
			.synchronizedList(new ArrayList<AuctionItem>());
	private Integer auctionItemIDCounter = 0;

	public int createAuction(String name, int minItemValue, Date closingDate)
			throws RemoteException {
		AuctionItem newAuction = new AuctionItem(++auctionItemIDCounter, name,
				minItemValue, closingDate);
		auctionItemList.add(newAuction);
		System.out.println("Auction item created.");
		return auctionItemIDCounter;
	}

	// clientID type may change
	public void performBid(AuctionClientIntf clientID, int auctionID, int bidValue) throws RemoteException {
		
	}

	public String getList() throws RemoteException {
		// for each auction in the list of auctions
		// display a toString() of that auction
		// format is UID, name, minItemValue, closingDate
		String itemList = "UID\tName\tMin Bid\tClosing Date";
		itemList += "\n------------------------------------------\n\n";
		for (AuctionItem auctionItem : auctionItemList) {
			itemList += auctionItem.UID + "\t" + auctionItem.name + "\t"
					+ auctionItem.minItemValue + "\t" + auctionItem.closingDate
					+ "\n";
		}
		return itemList;
	}

}